package edu.sdufe.service.impl;
import edu.sdufe.dao.SchoolDao;
import edu.sdufe.entity.School;
import edu.sdufe.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

public class SchoolServiceImpl implements SchoolService {
    private final SchoolDao schoolDao;

    @Autowired
    public SchoolServiceImpl(SchoolDao schoolDao) {
        this.schoolDao = schoolDao;
    }

    @Override
    public boolean save(School school) {
        return schoolDao.insert(school) > 0;
    }

    @Override
    public boolean update(School school) {
        return schoolDao.update(school) > 0;
    }

    @Override
    public boolean delete(Long id) {
        return schoolDao.deleteById(id) > 0;
    }

    @Override
    public School getById(Long id) {
        return schoolDao.selectById(id);
    }

    @Override
    public List<School> getAll() {
        return schoolDao.selectAll();
    }
}
